]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
appDisplay: Use a custom LayoutManager for the AllView stack
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 14 Mar 2013 18:08:46 +0000 (19:08 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 15 Mar 2013 21:41:54 +0000 (22:41 +0100)
ClutterBinLayout uses the maximum width/height of all children in
size requests and positions children according to the expand/align
properties. This means that the vertical position of folder popups
is not considered in size requests, so if the main view is smaller
than a folder popup's height and offset, the popup will be truncated
and/or mispositioned. Fix those cases by using a custom LayoutManager
that behaves like ClutterFixedLayout for height requests and like
ClutterBinLayout otherwise.

https://bugzilla.gnome.org/show_bug.cgi?id=694371

js/ui/appDisplay.js

index 79463b2ad2a5e8fd8546be95ac86903b146b095e..22ae481e5f5e7fdbbd60d4346e838243bf9c447c 100644 (file)
@@ -156,6 +156,30 @@ const FolderView = new Lang.Class({
     }
 });
 
+const AllViewLayout = new Lang.Class({
+    Name: 'AllViewLayout',
+    Extends: Clutter.BinLayout,
+
+    vfunc_get_preferred_height: function(container, forWidth) {
+        let minBottom = 0;
+        let naturalBottom = 0;
+
+        for (let child = container.get_first_child();
+             child;
+             child = child.get_next_sibling()) {
+            let childY = child.y;
+            let [childMin, childNatural] = child.get_preferred_height(forWidth);
+
+            if (childMin + childY > minBottom)
+                minBottom = childMin + childY;
+
+            if (childNatural + childY > naturalBottom)
+                naturalBottom = childNatural + childY;
+        }
+        return [minBottom, naturalBottom];
+    }
+});
+
 const AllView = new Lang.Class({
     Name: 'AllView',
     Extends: AlphabeticalView,
@@ -164,7 +188,7 @@ const AllView = new Lang.Class({
         this.parent();
 
         let box = new St.BoxLayout({ vertical: true });
-        this._stack = new St.Widget({ layout_manager: new Clutter.BinLayout() });
+        this._stack = new St.Widget({ layout_manager: new AllViewLayout() });
         this._stack.add_actor(this._grid.actor);
         this._eventBlocker = new St.Widget({ x_expand: true, y_expand: true });
         this._stack.add_actor(this._eventBlocker);